package com.test.seataorder.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.test.seataorder.dao.OrderDao;
import com.test.seataorder.entity.Order;
import com.test.seataorder.service.impl.OrderServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class OrderController {
    @Resource
    private OrderServiceImpl orderService;

    /**
     * 创建订单
     */
    @PostMapping("/create")
    public String create(@RequestBody Order order) {
        orderService.create(order);
        return "订单创建成功!";
    }

    @Resource
    private OrderDao orderDao;

    @GetMapping(value = "/test")
    public String test(){
        List<Order> orderList = orderDao.selectList(new QueryWrapper<>());
        Order order = new Order(1L,1L,1L,1,100.0,0);
        orderService.save(order);
        return "OK";
    }
}
